library(ggplot2)
library(gridExtra)
source('utils.R')
theme_set(theme_bw())

source('basic.R')
source('spatial.R')

n <- 21
X <- basic.funk(10/(n*n))
X. <- spatial.funk(n)

V <- X.[,1+(2*n*n+1):(3*n*n)]
t <- c(identity, log)
p <- list()
for(i in 1:2)
	p[[i]] <- eval(substitute({
		ggplot() +
			geom_line(aes(X[,1], t[[i]](X[,4]), linetype='nonspatial')) +
			geom_line(aes(X.[,1], t[[i]](apply(V, 1, mean)), linetype='spatial')) +
			expand_limits(y=0) +
			ggtitle(c('Virus load', 'Log virus load')[i]) +
			scale_linetype_manual(name='Models', values=c('nonspatial'=1, 'spatial'=2),
				labels=c('Non-spatial model', 'Average spatial\nmodel grid')) +
			theme(axis.title.x=element_blank(), axis.title.y=element_blank())
	}, list(i=i)))

grid.arrange_shared_legend(p)
